<?php
        define("GRID_SOURCE", "");
        
        include(GRID_SOURCE."class/gridclasses.php"); //Include the grid engine.
        
        session_start();
    	require_once "../funciones.php";
       
        //Define identifying name(s) to your grid(s). Must be unqiue name(s).
        $grid_id = array("grid");

        //Remember to comment the again line when publishing PHP Grid, or else PHP Grid wont remember the settings between page loads.
        unset($_SESSION["grid"]);
        include(GRID_SOURCE."class/gridcreate.php"); //Creates grid objects.
        
?>
<html>
        <head>
                <title>Invefisico de Equipos</title>
                <script language="Javascript" type="text/javascript" src="<?php print(GRID_SOURCE);?>javascript/javascript.js"></script>
                <link href="<?php print(GRID_SOURCE);?>css/style.css" rel="stylesheet" type="text/css">
				<script type='text/javascript' src="<?php print(GRID_SOURCE);?>server.php?client=all"></script>
				<script>
				HTML_AJAX.defaultServerUrl = '<?php print(GRID_SOURCE);?>server.php';
				</script>
                <script src="../js/jquery.js" type="text/javascript"></script>
                <script>
                function validar(e,serial)
                {
                    var tecla7;
                	
                	    if (document.all) { tecla7 = e.keyCode;  }
                	    else {  tecla7 = e.which; }
                	    
                	    if (tecla7 == 13) 
                		{ 
                			if ($('#bodega', top.document).attr('value') == 'XXX')
                			{
                				alert('Debe Primero seleccionar una Bodega');
                				$('#bodega', top.document).focus(); 
                			}
                			else
                			{
                				if ($('#item', top.document).attr('value') == 'XXX')
                				{
                					alert('Debe Primero seleccionar un Item');
                					$('#item', top.document).focus();
                				}
                				else
                                {
                                    if ($('#ctodos', top.document).attr('value') == '0')
                				    {
                    					alert('Debe Primero Indicar una Cantidad');
                    					$('#ccpu', top.document).focus();
                				    }
                                    else
                                        location.href="adiciona_fisico.php?serial="+serial;
                                }
                			}
                		}
                	    else
                		{ return false; }
                }
                </script>

        </head>

        <body onload="document.getElementById('Editbox1').focus();">

	<?php

	if ($_SESSION['caweb']['iniciar'] == 1)
	{
	?>
        Interno:<input type="text" id="Editbox1" onkeypress="validar(event,this.value);" size="15" name="Editbox1" value="" />
                <?php

			echo  "Ultimo Interno ".$_SESSION['caweb']['ultimointerno'];
		 	if ($_SESSION['caweb']['resultado'] == 1) { echo "<font size=4 color=green><b> CORRECTO </b></font>"; }
   			if ($_SESSION['caweb']['resultado'] == 3) { echo "<font size=4 color=red><b> INTERNO EN TRANSACCION ACTUAL </b></font>"; }
            if ($_SESSION['caweb']['resultado'] == 5) { echo "<font size=4 color=orange><b> Aun No hay autorizacion para Empezar </b></font>"; }

			$username=$_SESSION['caweb']['username'];
			$sucursal=$_SESSION['caweb']['sucursal'];
			$bodega=$_SESSION['caweb']['bodega'];

            $condicion="usuariocreo='$username' AND sucursal_f='$sucursal' AND bodega_f='$bodega'";
            $_SESSION["grid"]->SetDatabaseConnection($_SESSION['caweb']['basededatos'], "caweb", "caweb");
			$_SESSION["grid"]->SetSqlSelect('id,interno,item_l,sucursal_f,bodega_f', 'temporal_fisico',$condicion);
			$_SESSION["grid"]->SetUniqueDatabaseColumn("id", true);
			$_SESSION["grid"]->SetTitleName("Interno para Inventario de Equipos");
			$_SESSION["grid"]->SetEditModeEdit(true);
			$_SESSION["grid"]->SetMaxRowsEachPage(30);
       	    $_SESSION["grid"]->SetDatabaseColumnEditable("id", false);
			$_SESSION["grid"]->SetDatabaseColumnEditable("interno", true);
            $_SESSION["grid"]->SetDatabaseColumnEditable("sucursal_f", true);
			$_SESSION["grid"]->SetDatabaseColumnEditable("bodega_f", true);
			$_SESSION["grid"]->SetDatabaseColumnEditable("item_l", true);
			$_SESSION["grid"]->SetShowExcelIco(false);
			$_SESSION["grid"]->SetShowPrintIco(true);
			$_SESSION["grid"]->PrintGrid(MODE_EDIT);	
   }
   ?>

</body> 
</html>
